The invention relates to a keyboard interface for a computer and, more particularly, to a keyboard interface for use in computers incorporating terminate-and-stay-resident (TSR) programs which intercept operator keyboard inputs.
Many computers, such as personal computers, are used with keyboards as the primary operator input devices. In such a computer the keyboard is coupled to the processor of the computer through a keyboard interface, which receives signals corresponding to pressing or releasing of keys on the keyboard and makes such signals available to the processor and the user program being executed therein. In many personal computers, the signals from the keyboard are in serial digital format and are converted to parallel digital format by the keyboard interface before being made available to the parallel data bus of the processor. An example of such a serial-to-parallel keyboard interface is described and claimed in U.S. Pat. No. 4,460,957 to Eggebrecht et al.
Personal computers commonly use a Basic Input-Output System (BIOS) comprising routines executed by the processor to provide a standardized interface between an application's program and the personal computer. The use of a BIOS results in a measure of hardware independence across different personal computer makes and models. In particular, keyboard routines are included in the BIOS to permit the applications program to obtain keyboard input. The BIOS routines are stored in ROM in most personal computers, although in some personal computers some or all of the routines are stored in RAM.
The BIOS routines include a so-called INT 9 routine and a so-called INT 16 routine, both of which have to do with keyboard function. When information about a keystroke is sent from the keyboard to the personal computer, the keyboard interface receives the information, which is called a scancode, and generates a hardware interrupt which is called the scancode interrupt. This interrupt, which is hardware interrupt 9, prompts the CPU to execute the INT 9 routine of the BIOS, which services that interrupt. The INT 9 routine processes the scancode, and if the scancode is indicative of a key value, places that key value in a keyboard buffer in RAM. When an applications program is ready to receive a key value, it calls the INT 16 routine, which obtains a key value from the RAM keyboard buffer and provides it to the applications program.
Not every scancode corresponds to a key value. For example, by convention both the pressing and the releasing of a key cause the keyboard to send a respective scancode to the computer. While the pressing of a key may give rise to a respective key value, the releasing of a key does not. Furthermore, the pressing or releasing of a SHIFT, CTRL, or ALT key does not give rise to a key value, although corresponding scancodes are generated and communicated to the personal computer. The INT 9 routine of the BIOS monitors the status of the SHIFT, CTRL and ALT keys and uses such status in deriving a key value corresponding to a received scancode.
The design of a typical personal computer is such that an applications program may be designed to intercept the scancode interrupt after it has been generated by the keyboard interface circuitry but prior to (or in place of) the execution of the INT 9 routine of the BIOS. An example of such a program is "Sidekick", a commercially available program published by Borland International, which is loaded into the personal computer but not immediately executed. Only when the user types a particular key or key combination, called a "hot key", does execution of that program commence. Such a program usually takes advantage of a feature of DOS which permits a program to become a TSR (terminate-and-stay-resident) program. A TSR program is loaded by DOS into a portion of RAM, which is then protected by DOS during loading of other applications programs in RAM. A TSR that commences its own execution upon user entry of a "hot key" sequence will be referred to as a "hot key TSR".
A hot key TSR, then, typically intercepts each scancode interrupt, inspects the scancode in the scancode port of the keyboard interface and, except where the scancode is that of the predefined "hot key", passes control on to the INT 9 routine of the BIOS. Where the scancode in the scancode port is that of the predefined "hot key", then the TSR commences execution of its own code.
The design of the typical BIOS is such that a user may choose to load a plurality of TSRs into the personal computer, each with its own associated hot key. Each time a scancode interrupt is generated by the keyboard interface, a chain of tests occurs. Each TSR in turn causes the inspection of the scancode port to determine if the scancode present at the scancode port represents its hot key. This may continue until the last TSR to inspect the contents of the scancode port without finding its hot key passes control to the INT 9 routine of the BIOS. The INT 9 routine derives a key value from the scancode and places the key value in the RAM keyboard buffer.
In some personal computers, particularly old models including the original IBM PC, the scancode present in the scancode port of the keyboard interface remains "valid", i.e. does not change, until such time as the scancode port is cleared by the CPU by means of a clear signal provided by the CPU to a port established for such control of the keyboard interface. In such computers, the BIOS INT 9 routine would send such a clear signal after receiving and processing each scancode.
In personal computers of more recent manufacture, including many personal computers designed to be compatible with the IBM PC AT, the scancode present in the scancode port of the keyboard interface remains valid for only a limited period of time (typically 1 millisecond) after first being read by the CPU.
The use of hot key TSRs in personal computers of the latter type has the problem in that if multiple hot key TSRs are used, by the time the last of the TSRs in its turn inspects the contents of the scancode port, such contents may have been replaced by a subsequent scancode received from the keyboard. Because the last of the TSRs may be unable to determine if the contents represent its hot key and BIOS itself may not be able to obtain key value information from the scancode port, keystrokes may be lost.
This problem with the use of hot key TSRs in personal computers of the latter type is exacerbated if there are numerous interrupt-driven background tasks using up some of the data bus's time during the limited interval during which all the TSRs must inspect the contents of the scancode port. Typical examples of such tasks are print spoolers and network handlers.
One feature provided by some personal computer makers is intended, among other things, to provide a way to avoid the above described problems. A so-called subservice 4F of interrupt 15 permits an applications program or TSR to be notified whenever new information has arrived at the scancode port. The intercepting applications program or TSR stores its own address in the INT 15 interrupt vector location, saving the previous contents of that location. The BIOS of such personal computers is designed so that when the INT 9 routine is executed in response to receipt of a scancode interrupt from the keyboard interface, the scancode from the scancode port is obtained, and before a key value is derived from that scancode, the routine calls interrupt 15H after having placed the value 4FH in a particular CPU register and the scancode in another particular CPU register. Because the intercepting TSR has stored its own address in the INT 15 location, control passes to the intercepting TSR. The intercepting TSR then tests for the 4FH value, and if the value is not 4FH, jumps to the address pointed to by the saved previous contents of that location. The result is that control passes to the address to which it would have passed if the TSR had not been installed. If the value is 4FH, the TSR retrieves the scancode and determines whether the scancode is indicative of the hot key of the TSR. If not, then the TSR jumps to the saved address just as it does when, as previously mentioned, the 4FH value is not found. If the scancode is indicative of the hot key, then the TSR retains control.
Such a TSR need not obtain the scancode from the scancode port, but instead gets it from the CPU register. Thus the above-mentioned problem that the scancode at the scancode port may no longer be valid when inspected by the TSR is avoided. Furthermore, assuming that the INT 9 routine managed to obtain the scancode from the scancode port within the one-millisecond interval, then the TSR can be assured of not having missed a scancode, even if the provision of the scancode to the TSR by way of CPU register occurs subsequent to the end of the one-millisecond interval during which the scancode at the port remained valid.
The availability of the subservice 4F in some personal computers does not, however, provide a satisfactory solution to the problem of multiple hot key TSRs. This is because most designers of hot key TSRs do not use the subservice 4F, as it is not available on all personal computers. Instead, most designers of hot key TSRs use the INT 9 interception technique described above.
In some personal computers, the keyboard interface is made so that it may be disabled from receiving additional scancodes by means of a command from the CPU, and reenabled by means of another command. It would thus be possible, in such personal computers, for the TSR to be designed so that whenever it intercepts a scancode interrupt, it immediately disables the keyboard interface. The keyboard interface would be reenabled only after the scancode has been processed.
Just as with the subservice 4F, however, the ability to disable the keyboard interface in some personal computers likewise does not provide a satisfactory solution to the problem of multiple hot key TSRs. The design of existing hot key TSRs would have to be changed to bring about the disabling. Further, the disabling and enabling commands issued for each scancode received from the keyboard would use up bus bandwidth.
Thus a need clearly exists for an object of the present invention to a computer keyboard interface which uses TSR programs for intercepting operator keyboard inputs but which avoids the problem of lost keystrokes without requiring special subservices or significant use of bus bandwidth and without requiring redesign of existing TSR programs.